#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <cstdlib>
#include <climits>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    ll C = 0;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] < 0) {
            C += a[i];
        }
    }

    vector<ll> b;
    for (ll x : a) {
        b.push_back(abs(x));
    }
    sort(b.begin(), b.end());

    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<>> pq;
    pq.push({0, 0});

    vector<ll> ans;
    while (ans.size() < k && !pq.empty()) {
        auto [sum, idx] = pq.top();
        pq.pop();
        if (idx == n) {
            ans.push_back(sum + C);
        } else {
            pq.push({sum, idx + 1});
            pq.push({sum + b[idx], idx + 1});
        }
    }

    for (ll i = 0; i < ans.size(); i++) {
        cout << ans[i];
        if (i < ans.size() - 1) {
            cout << ' ';
        }
    }
    cout << endl;

    return 0;
}